# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from cerbero.utils import shell

class Recipe(recipe.Recipe):
    name = 'tremor'
    version = '1.2.1+r19427'
    stype = SourceType.SVN
    url = 'https://svn.xiph.org/trunk/Tremor/'
    revision = '19427'
    licenses = [License.BSD_like]
    deps = ['libogg']
    config_sh = 'sh autogen.sh'
    patches = ['tremor/0001-Prevent-symbol-conflicts.patch',
               'tremor/0002-Try-fixing-shared-build.patch',
               'tremor/0003-Map-remaining-symbol-too.patch',
               'tremor/0004-Fix-build-with-the-Android-NDK-for-x86.patch',
               'tremor/0005-configure-check-for-machine-endianness.patch',
               'tremor/0006-tremor-floor-mapping-residue-function-renaming.patch',
               'tremor/0007-tremor-more-function-renaming.patch',
               'tremor/0008-fix-more-duplicated-symbols.patch']

    files_libs = ['libvorbisidec']
    files_devel = [
        'include/tremor', 'lib/pkgconfig/vorbisidec.pc']

    def prepare(self):
        if self.config.target_arch == Architecture.ARMv7:
            if self.config.target_platform != Platform.IOS:
                self.new_env['CFLAGS'] = os.environ['CFLAGS'] + " -Wa,-mimplicit-it=thumb "
        elif self.config.target_arch == Architecture.ARM:
            self.new_env['CFLAGS'] = os.environ['CFLAGS'].replace('-mthumb', '')

    def configure(self):
        if self.config.target_platform == Platform.IOS:
            shell.replace(os.path.join(self.build_dir, 'configure.in'), {'-D_ARM_ASSEM_':''})
        super(recipe.Recipe, self).configure()
